package main

import "fmt"

func main() {
	fmt.Printf("Hello World!\n")
	map1 := make(map[string]string)
	map1["name"] = "张三"
	map1["address"] = "刚在奇偶"
	fmt.Printf("map1: %v\n", map1)

	fmt.Printf("map1[\"xxx\"]: %v\n", map1["xxx"])
	if map1["xxx"] == "" {
		fmt.Println("map1 没有 xxx")
	}

	val, ok := map1["xxx"]
	if ok {
		fmt.Println(val)
	} else {
		fmt.Println("no xxx")
	}

	// if 判断配套使用
	if val, ok := map1["name"]; ok {
		fmt.Println(val)

	}

	// for range 配套使用
	map1["hello"] = "world"
	for key, value := range map1 {
		fmt.Printf("key: %v, value: %v\n", key, value)
	}

}
